public class Main {
    public static List<int[]> DFS(List<int[]> list, int[] books, int[] boxes, int idx, int n) {
        if (idx == n) {
            int[] box = boxes.clone();
            list.addAll(Collections.singleton(box));
            return list;
        }
        for (int i = 0; i < n; i++) {
            if (books[i] == 0) {
                boxes[idx] = i + 1;
                books[i] = 1;

                //放下一个箱子
                DFS(list, books, boxes, idx + 1, n);
                //回溯
                books[i] = 0;
            }
        }
        return list;
    }
}